<php>
	$this->display(tpl('head',true));
	$type[$data['type']]="checked";
	$dis="";
	if($data['type'] != 2){
		$dis=' style="display: none;"';
	}
	$dis1="";
	$dis2="";
	if($data['type']==1 || $data['type']==2){
		$dis1=' style="display: none;"';
	}
	$setting=unserialize($data['setting']);
</php>

<style>
	.layui-tab{
		padding-left: 20px;
	}
	.layui-form-select {
	    position: relative;
	    width: 30%;
	}
	.layui-input-my {
	    display: block;
	    width: 30%;
	    padding-left: 10px;
	}
	.layui-form-checkbox{
		margin: 5px 10px 5px 0;
	}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>分类/栏目修改</legend>
</fieldset>
<form class="layui-form"  method="post" >
<div class="layui-tab">
	<ul class="layui-tab-title">
	    <li class="layui-this">基本设置</li>
	    <li>SEO设置</li>
	    <li>模板设置</li>
	    <li>权限设置</li>
	</ul>
	<div class="layui-tab-content">
	    <div class="layui-tab-item layui-show">
	    	<table class="layui-table  my-tabel">
	    		<tbody>
	    			<tr>
	    				<td>栏目名称</td>
	    				<td>
	    					<input name="name" id="name" value="{{$data['name'] }}" placeholder="请输入栏目名称" class="layui-input layui-input-my" type="text">
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>栏目类型</td>
	    				<td>
	    					<input name="type" value="0" lay-filter="type" title="栏目" type="radio" {{$type['0'] }}>
			    			<input name="type" value="1" lay-filter="type" title="分类" type="radio" {{$type['1'] }}>
			    			<input name="type" value="2" lay-filter="type" title="单页" type="radio" {{$type['2'] }}>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>所属分类</td>
	    				<td>
	    					<select name="fup">
	    						<option value="">顶级分类</option>
								<foreach array="allcidDB">
								<php>
									$selected=$data['upcid']==$row['cid'] ? " selected" : '';
								</php>
								<option value="{{$row['cid'] }}"{{$selected }}>{{$row['levels']; echo $row['name'] }}</option>
								</foreach>
	    					</select>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>所属内容模型</td>
	    				<td>
	    					<select name="mid">
	    						<option value="">不使用模型</option>
								<foreach array="moduleDB">
								<php>
									$selected=$data['cmid']==$row['id'] ? "selected" : '';
								</php>
	               				<option value="{{$row['id'] }}" {{$selected }}>{{$row['name'] }}</option>
								</foreach>
	    					</select>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>栏目目录</td>
	    				<td>
	    					<input name="dir_name" id="dir_name" value="{{$data['dir_name'] }}" lay-verify="dir_name" placeholder="请输入栏目目录,英文或者数字" class="layui-input layui-input-my left" type="text">
	    					<a href="javascript:void();" onclick="shengcheng()" style="float: left;height: 45px;line-height: 35px;padding-left: 10px;color: red;">一键生成</a>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>列表页显示条数</td>
	    				<td>
	    					<input name="setting[rows]" value="{{$setting['rows'] }}"  class="layui-input layui-input-my left" type="number">
	    					<span style="height: 45px;line-height: 35px;padding-left: 10px">如果不填或者为0默认为20</span>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>列表页每条显示字数</td>
	    				<td>
	    					<input name="setting[number]" value="{{$setting['number'] }}"  class="layui-input layui-input-my left" type="number">
	    					<span style="height: 45px;line-height: 35px;padding-left: 10px">如果不填或者为0默认为30个字符</span>
	    				</td>
	    			</tr>
	    			<tr id="danyecontent" {{$dis }}>
	    				<td>单页内容</td>
	    				<td>
	    					<textarea name="content" style="height:500px; width: 100%;" id="content" placeholder="单页内容" >{{$data['content'] }}</textarea>
							<script type="text/javascript">
								var ue = UE.getEditor('content',{
									zIndex : 900,
									autoHeightEnabled:false,
								    // 服务器统一请求接口路径
								    serverUrl: "/admin/index/plugin/ueditor/setting/ueditor_config/",
								    toolbars: [[
								        'source', '|', 'undo', 'redo', '|',
								        'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
								        'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
								        'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
								        'directionalityltr', 'directionalityrtl', 'indent', '|',
								        'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
								        'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
								        'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
								        'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
								        'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
								        'print', 'preview', 'searchreplace', 'drafts', 'help'
								    ]]});
							</script>
	    				</td>
	    			</tr>
	    		</tbody>
	    	</table>
	    </div>
	    <div class="layui-tab-item">
	    	<table class="layui-table  my-tabel">
	    		<tbody>
	    			<tr>
	    				<td>SEO标题</td>
	    				<td>
	    					<input name="seo_name" value="{{$data['seo_name'] }}" placeholder="请输入本栏目优化标题" class="layui-input layui-input-my" type="text">
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>SEO关键字</td>
	    				<td>
	    					<input name="seo_keywords" value="{{$data['seo_keywords'] }}" placeholder="请输入本栏目优化关键字" class="layui-input layui-input-my" type="text">
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>SEO描述</td>
	    				<td>
	    					<input name="seo_description" value="{{$data['seo_description'] }}" placeholder="请输入本栏目优化描述" class="layui-input layui-input-my" type="text">
	    				</td>
	    			</tr>
		    	</tbody>
		    </table>
	    </div>
	    <div class="layui-tab-item mytemp">
	    	<table class="layui-table  my-tabel">
	    		<tbody>
	    			<tr {{$dis1 }}>
	    				<td>内容模板</td>
	    				<td>
	    					<input name="setting[tpl][article]" value="{{$setting['tpl']['article'] }}" id="tplcontent" class="layui-input layui-input-my left" type="text">
			    			<select class="left" id="setting_content">
			    				<option value="0">请选择一个模板</option>
			               		<option value="articles">默认模板</option>
								<foreach array="article_template">
			               		<option value="{{$row['file'] }}">{{$row['name'] }}</option>
								</foreach>
			    			</select>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>列表模板</td>
	    				<td>
	    					<input name="setting[tpl][category]" value="{{$setting['tpl']['category'] }}" id="tplcategory" class="layui-input layui-input-my left" type="text">
			    			<select class="left" id="setting_list">
			    				<option value="0">请选择一个模板</option>
			               		<option value="category">默认模板</option>
								<foreach array="list_template">
			              		<option value="{{$row['file'] }}">{{$row['name'] }}</option>
								</foreach>
			    			</select>
	    				</td>
	    			</tr>
	    			
		    	</tbody>
		    </table>
	    	<blockquote class="layui-elem-quote layui-text">
			  	<p>1.内容模板,列表模板,你都可以自己做一个,然后在上面输入他们所在的目录即可调用显示.留空的话.将以默认为标准.</p>
			  	<p>2.模板里可以加载{include="head.htm"}{include="foot.htm"}碎片。程序会自动编译。</p>
			</blockquote>
	    </div>
	    <div class="layui-tab-item">
	    	<table class="layui-table  my-tabel">
	    		<tbody>
	    			<tr>
	    				<td>内容查看权限</td>
	    				<td>
							<foreach array="C('USER_GROUP')" f="1">
	    					<php>
	    						$checked= in_array($key,(array)$setting['look']) ? 'checked' : '';
	    					</php>
	    						<input {{$checked }} type="checkbox" name="setting[look][]"  value="{{$key }}" title="{{$row['name']; }}"/>
	    					</foreach>
	    				</td>
	    			</tr>
	    			<tr>
	    				<td>会员中心信息发布&修改权限</td>
	    				<td>
	    					<table class="layui-table  my-tabel">
					    		<tbody>
									<foreach array="C('USER_GROUP')" f="1">
					    			<php>
					    				$add=$is_state=$is_edit=$is_edit_state=$is_sell=$is_pass=$is_comment=$is_state_no_del=$is_state_yes_del='';
					    				foreach($setting['power'][$key] as $_key=>$v){
					    					$$_key='checked';
					    				}
					    			</php>
					    			<tr>
					    				<td width="150">【{{$row['name']; }}】权限设置</td>
					    				<td>
					    					<input {{$add }} type="checkbox" name="setting[power][{{$key }}][add]" value="1" title="允许发布内容"/>
					    					<input {{$is_state }} type="checkbox" name="setting[power][{{$key }}][is_state]" value="1" title="发布内容时直接审核"/>
					    					<input {{$is_edit }} type="checkbox" name="setting[power][{{$key }}][is_edit]" value="1" title="审核后的内容可以修改"/>
					    					<input {{$is_edit_state }} type="checkbox" name="setting[power][{{$key }}][is_edit_state]" value="1" title="修改后的内容直接审核"/>
					    					<input {{$is_sell }} type="checkbox" name="setting[power][{{$key }}][is_sell]" value="1" title="允许发布出售文章"/>
					    					<input {{$is_pass }} type="checkbox" name="setting[power][{{$key }}][is_pass]" value="1" title="允许发布加密文章"/>
					    					<input {{$is_comment }} type="checkbox" name="setting[power][{{$key }}][is_comment]" value="1" title="允许开启或关闭评论"/>
					    					<input {{$is_state_no_del }} type="checkbox" name="setting[power][{{$key }}][is_state_no_del]" value="1" title="允许删除自己未审核的文章"/>
					    					<input {{$is_state_yes_del }} type="checkbox" name="setting[power][{{$key }}][is_state_yes_del]" value="1" title="允许删除自己已审核的文章"/>
					    				</td>
					    			</tr>
					    			</foreach>
					    			<tr>
					    				<td colspan="2">
					    					<p>以上设置勾选为有权限，否则则没有权限</p>
					    				</td>
					    			</tr>
						    	</tbody>
						    </table>
	    				</td>
	    			</tr>
	    			
		    	</tbody>
		    </table>
	    </div>
  	</div>
 
  	<table class="layui-table  my-tabel">
	   	<tbody>
	    	<tr>
	    		<td class="my-button">
	    			<input type="hidden" name="step" value="post" />
					<input type="hidden" name="cid" value="{{$data['cid'] }}" />
					<button class="layui-btn">立即设置</button>
	    		</td>
	    	</tr>
		</tbody>	
	</table>
</div>
</form>
<script type="text/javascript">
	function shengcheng(){
		var name=document.getElementById("name").value;
		$.ajax({
			url:"/admin/pinyin/pinyin/json_true/name_"+name,
		    type: 'get',
		    dataType: 'json',
		    success: function(data){
		    	if(data.code==0){
		    		document.getElementById("dir_name").value=data.pinyin;
		    		return false;
		    	}
		       alert(data.text);
		    }
		})
	}
	layui.use(['form', 'layedit', 'laydate','element'], function(){
	  	var $ = layui.jquery
	  	,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
	  	$('.site-demo-active').on('click', function(){
	    	var othis = $(this), type = othis.data('type');
	    	active[type] ? active[type].call(this, othis) : '';
	  	});
	  	var form = layui.form;
	  	//监听指定开关
  		form.on('radio(type)', function(data){
    		if(data.value==2){
    			$('#layui_list').hide("slow");
    			$('#layui_content').hide("slow");
    			$('#danyecontent').show("slow");
    		}else{
    			$('#layui_list').show("slow");
    			$('#layui_content').hide("slow");
    			$('#danyecontent').hide("slow");
    		}
  		});
	});
$(document).ready(function(){
   	$("#setting_head").change(function(){
       	var selected=$(this).children('option:selected').val();
       	if(selected==0){
           	$("#tplhead").val("");
       	}else{
           	$("#tplhead").val(selected);
       	}
   	});
   	$("#setting_foot").change(function(){
   	    var selected=$(this).children('option:selected').val();
       if(selected==0){
        	$("#tplfoot").val("");
      	}else{
      	    $("#tplfoot").val(selected);
     	}
   	});
   	$("#setting_content").change(function(){
   	    var selected=$(this).children('option:selected').val();
       if(selected==0){
        	$("#tplcontent").val("");
      	}else{
      	    $("#tplcontent").val(selected);
     	}
   	});
   	$("#setting_list").change(function(){
   	    var selected=$(this).children('option:selected').val();
       if(selected==0){
        	$("#tplcategory").val("");
      	}else{
      	    $("#tplcategory").val(selected);
     	}
   	});
   	$("#setting_onepage").change(function(){
   	    var selected=$(this).children('option:selected').val();
       if(selected==0){
        	$("#tplonepage").val("");
      	}else{
      	    $("#tplonepage").val(selected);
     	}
   	});
});
</script>
<php> $this->display(tpl('foot',true)); </php>   
